package com.zhugang.week01;

/**
 * @program algorithms
 * @description: defangIpaddr
 * @author: chanzhugang
 * @create: 2022/05/21 22:00
 */
public class DefangIPaddr {

    /**
     * 1108.IP地址无效化
     *
     * @param address
     * @return
     */
    public String defangIPaddr(String address) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < address.length(); i++) {
            char c = address.charAt(i);
            if (c == '.') {
                sb.append("[.]");
            } else {
                sb.append(c);
            }
        }
        return sb.toString();
    }
}